import { useState } from "react";
import store from "../redux";
import { getCartActions } from "../redux/action/getCartAction";
import { setPasswordActions } from "../redux/action/userActions";
export default function Home() {
  let [list, setList] = useState(store.getState().cartReducer.cartList);
  store.subscribe(()=>{
    setList(store.getState().cartReducer.cartList)
  })
  return (
    <div>
      <h1>home</h1>

      <h3>购物车数量：{list.length}</h3>
      <button
        onClick={() => {
          console.log(store);
          // 每次加
          store.dispatch(getCartActions("手机"));
        }}
      > 加入购物车</button>
      <button onClick={()=>{
        store.dispatch(setPasswordActions(987654))
      }}>修改用户密码</button>
    </div>
  );
}
